package com.che.software.testato.business;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.che.software.testato.domain.entity.ReferenceTableTuple;
import com.che.software.testato.util.jsf.faces.LocaleUtil;

/**
 * Manager dedicated to the references.
 * 
 * @author Clement HELIOU (clement.heliou@che-software.com).
 * @copyright Che Software.
 * @license GNU General Public License.
 * @since July, 2011.
 * 
 *        This file is part of Testato.
 * 
 *        Testato is free software: you can redistribute it and/or modify it
 *        under the terms of the GNU General Public License as published by the
 *        Free Software Foundation, either version 3 of the License, or (at your
 *        option) any later version.
 * 
 *        Testato is distributed in the hope that it will be useful, but WITHOUT
 *        ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 *        FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 *        for more details.
 * 
 *        You should have received a copy of the GNU General Public License
 *        along with Testato. If not, see <http://www.gnu.org/licenses/>.
 * 
 *        Testato's logo is a creation of Arrioch
 *        (http://arrioch.deviantart.com/) and it's distributed under the terms
 *        of the Creative Commons License.
 */
@Service("referencesManager")
public class ReferencesManager {

	/**
	 * Constants.
	 */
	private static final Logger LOGGER = Logger.getLogger(ReferencesManager.class);
	private static final String FIVE_DEFINITION_RESSOURCE_NAME = "criticalValueOrGreater", FIVE_DETAILS_RESSOURCE_NAME = "experienceStronglyPromotesARequirement", NINE_DEFINITION_RESSOURCE_NAME = "extremeValue", NINE_DETAILS_RESSOURCE_NAME = "requirementEasilyPromotedComparedToAnother", ONE_DEFINITION_RESSOURCE_NAME = "sameValue", ONE_DETAILS_RESSOURCE_NAME = "twoRequirementsAreEquals", SEVEN_DEFINITION_RESSOURCE_NAME = "veryHighValue", SEVEN_DETAILS_RESSOURCE_NAME = "requirementStronglyPromotedAndDominanceDemonstratedInPractice", THREE_DEFINITION_RESSOURCE_NAME = "valueSlightlyHigher", THREE_DETAILS_RESSOURCE_NAME = "experienceSlightlyPromotesARequirement";

	/**
	 * Members.
	 */
	private List<ReferenceTableTuple> referenceTable;

	/**
	 * Getter for the private field value referenceTable.
	 * 
	 * @return the referenceTable field value.
	 */
	public List<ReferenceTableTuple> getReferenceTable() {
		if (null == referenceTable) {
			LOGGER.debug("getReferenceTable(): initialization.");
			referenceTable = new ArrayList<ReferenceTableTuple>();
			referenceTable.add(new ReferenceTableTuple(1, LocaleUtil.getResourceBundleStringByName(ONE_DEFINITION_RESSOURCE_NAME), LocaleUtil.getResourceBundleStringByName(ONE_DETAILS_RESSOURCE_NAME)));
			referenceTable.add(new ReferenceTableTuple(3, LocaleUtil.getResourceBundleStringByName(THREE_DEFINITION_RESSOURCE_NAME), LocaleUtil.getResourceBundleStringByName(THREE_DETAILS_RESSOURCE_NAME)));
			referenceTable.add(new ReferenceTableTuple(5, LocaleUtil.getResourceBundleStringByName(FIVE_DEFINITION_RESSOURCE_NAME), LocaleUtil.getResourceBundleStringByName(FIVE_DETAILS_RESSOURCE_NAME)));
			referenceTable.add(new ReferenceTableTuple(7, LocaleUtil.getResourceBundleStringByName(SEVEN_DEFINITION_RESSOURCE_NAME), LocaleUtil.getResourceBundleStringByName(SEVEN_DETAILS_RESSOURCE_NAME)));
			referenceTable.add(new ReferenceTableTuple(9, LocaleUtil.getResourceBundleStringByName(NINE_DEFINITION_RESSOURCE_NAME), LocaleUtil.getResourceBundleStringByName(NINE_DETAILS_RESSOURCE_NAME)));
		}
		return referenceTable;
	}

	/**
	 * Setting a value to the referenceTable field.
	 * 
	 * @param referenceTable the value to set.
	 */
	public void setReferenceTable(List<ReferenceTableTuple> referenceTable) {
		this.referenceTable = referenceTable;
	}
}